def gcd(a, b) :
	if(b == 0):
		return a
	return gcd(b, a%b)
n = int(input().split()[0])
m = int(input().split()[0])
print(gcd(n,m))